/**
 * Group(圈子)导航页面相关数据、方法
 */
import { reactive, ref } from "vue";
import type { ITabsList } from "@/simba/types";
import type { ICircleItem } from "@/simba/types/circle";
import type { siTabsInstance } from "@/simba/types/component.d";

export const useCircleTabs = () => {
	const tabList = [
			{id: 0, name: '推荐'},
			{id: 1, name: '追随'},
			{id: 2, name: '附近'}
		]
	let circleTabs = reactive<ITabsList>({
		list: tabList,
		choosedTab: tabList[0]//默认为选择，与list中的
	})
	const keyword = ref('');
	const circleTabRef = ref<siTabsInstance>();//
	return {
		circleTabs, circleTabRef, keyword
	}
}
export const useCircleList=()=>{
	let circleList = reactive<ICircleItem[]>([])
	
	function onGetCircleDataHandler(){
		circleList.push({
			id:45,
			name:'月季1',
			imgUrl:'https://uview-plus.jiangruyi.com/album/1.jpg',
			introduce:'月季1月季1月季1月季1月季1月季1月季1月季1',
			recommendation: 21,
			follow:51,
			checked:true
		},
		{
			id:56,
			name:'月季2',
			imgUrl:'https://uview-plus.jiangruyi.com/album/2.jpg',
			introduce:'月季2月季2月季2月季2月季2月季2月季2月季2',
			recommendation: 22,
			follow:52,
			checked:true
		},
		{
			id:89,
			name:'月季3',
			imgUrl:'https://uview-plus.jiangruyi.com/album/3.jpg',
			introduce:'月季3月季3月季3月季3月季3月季3月季3月季3月季3',
			recommendation: 23,
			follow:53,
			checked:true
		},
		{
			id:12,
			name:'月季4',
			imgUrl:'https://uview-plus.jiangruyi.com/album/4.jpg',
			introduce:'月季4月季4月季4月季4月季4月季4月季4月季4月季4',
			recommendation: 23,
			follow:54,
			checked:true
		})
	}
	
	function onRecommendHandler(obj: ICircleItem) {
		console.log('circle-onRecommendHandler', obj.id)
		uni.showToast({
			icon: 'none',
			title: 'onRecommendHandler--' + obj.name
		})
	}
	function onFollowHandler(obj: ICircleItem) {
		console.log('circle-onFollowHandler', obj.id)
		uni.showToast({
			icon: 'none',
			title: 'onFollowHandler--' + obj.name
		})
	}
	return {
		circleList, onGetCircleDataHandler, onRecommendHandler, onFollowHandler
	}
}